package com.ciko.code.base;

import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import com.ciko.code.adapter.TabPagerAdapter;
import com.ciko.code.views.SwingLableBarWeight;
import com.mywork.R;
import java.util.List;

/**
 * Created by ciko on 2015/11/14.
 */
public abstract class BaseLabelActivity extends BaseActicity {

    private static SwingLableBarWeight slb_titleLabel;

    private ViewPager vp_contentLabel;

    private List<Fragment> mFragmentList;
    private String[] mTitleArr;

    private static TabPagerAdapter tabPagerAdapter;

    @Override
    protected void initLayout() {
        setContentView(R.layout.activity_base_label);
    }

    @Override
    protected void initView() {
        vp_contentLabel = findViewByID(R.id.vp_contentLabel);
        slb_titleLabel = findViewByID(R.id.slb_titleLabel);
    }

    protected void setFragmentList(List<Fragment> fragmentList, String[] titleArr) {
        tabPagerAdapter = new TabPagerAdapter(getSupportFragmentManager(), fragmentList, titleArr);
        vp_contentLabel.setAdapter(tabPagerAdapter);
        slb_titleLabel.setViewPager(vp_contentLabel);
    }

    protected void setDefaultPage(int position){
        vp_contentLabel.setCurrentItem(position);
        slb_titleLabel.onSelected(position);
    }

    public static void reslf(String[] titleArr) {
        tabPagerAdapter.setTitle(titleArr);
        slb_titleLabel.notifyDataSetChanged(2);
        tabPagerAdapter.notifyDataSetChanged();
    }

//    protected void initNotfAdapter(){
//        tabPagerAdapter.notifyDataSetChanged();
//    }

    @Override
    protected void initDates() {
        initLayoutDate();
    }

    protected abstract void initLayoutDate();

}
